class UsersController < ApplicationController
  layout 'login'
  skip_before_filter :login_required, :only => [:new, :create]

  def new
    @user = User.new
  end

  def create
    @user = User.new(params[:user])
    if @user.save
      flash[:notice] = "Creato nuovo utente."
      redirect_to root_url
    else
      render :action => 'new'
    end
  end

  def show
    @user = @current_user
  end

  def edit
    @user = @current_user
  end
  
  def update
    @user = @current_user
    if @user.update_attributes(params[:user])
      flash[:notice] = "Utente modificato."
      redirect_to :action => 'show'
    else
      render :action => :edit
    end
  end
end
